package com.example.md.mddemo.repo;

import com.example.md.mddemo.entity.Customer;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import java.util.List;

/**
 * Copyright © 2018年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * TODO:亲爱的临江仙，请写点注释吧...........
 * @Date 2018/8/9 18:34
 */
public interface CustomerRepository extends MongoRepository<Customer,ObjectId> {

    //根据客户编号返回客户合同相关信息
    @Query(value="{ 'custCode' : ?0 }", fields="{ 'contactList' : 1}")
    List<Customer> findCustomersByCustCode(String custCode);

    //根据客户编号返回客户名称，默认的_id不用返回
    @Query(value="{ 'custCode' : ?0 }", fields="{ 'custName' : 1,'_id' : 0}")
    List<String> findCustomerByCustCode(String custCode);
}
